package q1704_halvesAreAlike;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

public class Solution {
    /*
    判断字符串的两半是否相似
    遍历即可解决
     */
    public boolean halvesAreAlike(String s) {
        Set<Character> set = new HashSet<>();
        Collections.addAll(set, 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U');
        int n = s.length() / 2, cnt = 0;
        for (int i = 0; i < n; i++) {
            if (set.contains(s.charAt(i))) ++cnt;
        }
        for (int i = n; i < s.length(); i++) {
            if (set.contains(s.charAt(i))) --cnt;
        }
        return cnt == 0;
    }
}
